﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Bussiness.MobileBanking;
using FOModels.MobileBanking;
using Bussiness.Company;
using FOModels.Company;
using Bussiness.Language;
using FOModels.Language;
using System.Net;
using FOSystem.CultureHelper;
using Bussiness.Product;
using FOModels.Product;
using Bussiness.ProductFAQ;
using FOModels.ProductFAQ;
using Bussiness.Status;
using FOModels.Status;
using System.Configuration;
using System.Net.Mail;
namespace FO.Controllers
{
    public class MobileBankingController : CultureController
    {
        //
        // GET: /MobileBanking/

        public ActionResult Index()
        {
            MobileBankingBLL cardbll = new MobileBankingBLL();
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            ProductBLL probll = new ProductBLL();
            int MobileBankingID = int.Parse(System.Configuration.ConfigurationManager.AppSettings["MobileBankingID"].ToString());
            ViewBag.MobileBanking = cardbll.getMobileBankingList(lang.LangID);
            ViewBag.ProDes = probll.getProductByID(MobileBankingID, lang.LangID);
            return View();
        }
        public ActionResult MobileBankingInfo(int MobileBankingID)
        {
            MobileBankingBLL cardbll = new MobileBankingBLL();
            LanguageBLL langbll = new LanguageBLL();
            ProductFAQBLL faqbll = new ProductFAQBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            int MobileBankingIDs = int.Parse(System.Configuration.ConfigurationManager.AppSettings["MobileBankingID"].ToString());
            MobileBankingModels list = new MobileBankingModels();
            list = cardbll.GetMobileBankingByID(MobileBankingID, lang.LangID);
            ViewBag.FAQ = faqbll.getfaqbyproid(MobileBankingIDs, lang.LangID);
            Fcom.IDLib.SaveMoneyID.AccountsynClient client = new Fcom.IDLib.SaveMoneyID.AccountsynClient();
            FOModels.User.User us = null;
            if (User.Identity.Name != "")
            {
                Fcom.IDLib.SaveMoneyID.FullUserInfo fullinfo = client.getUserInfo(User.Identity.Name);
                us = new FOModels.User.User();
                us.DisplayName = fullinfo.Fullname;
                us.Email = fullinfo.Email;
                us.GroupID = fullinfo.GroupID;
                us.Status = fullinfo.Status;
                us.Username = fullinfo.Username;
                us.Phone = fullinfo.Phone;
                us.DOB = fullinfo.DateOfBirth;

            }
            ViewBag.UserInfo = us;


            return View(list);
        }
        public ActionResult Detail(int MobileBankingID)
        {
            MobileBankingBLL cardbll = new MobileBankingBLL();
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            ProductFAQBLL faqbll = new ProductFAQBLL();
            MobileBankingModels card = new MobileBankingModels();
            int MobileBankingIDs = int.Parse(System.Configuration.ConfigurationManager.AppSettings["MobileBankingID"].ToString());
            card = cardbll.GetMobileBankingByID(MobileBankingID, lang.LangID);
            ViewBag.FAQ = faqbll.getfaqbyproid(MobileBankingIDs, lang.LangID);

            return View(card);
        }
        [Authorize(Roles = "8,9")]
        public ActionResult ManagerMobileBanking()
        {
            return View();
        }
        public JsonResult getMobileBankingJson()
        {
            MobileBankingBLL cardbll = new MobileBankingBLL();
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            List<MobileBankingModels> list = new List<MobileBankingModels>();
            list = cardbll.GetAllToManager(lang.LangID);
            return Json(list, JsonRequestBehavior.AllowGet);
        }
        [HttpGet]
        [Authorize(Roles = "8,9")]
        public ActionResult InsertMobileBanking()
        {
            MobileBankingBLL bankingbll = new MobileBankingBLL();
            CompanyBLL bll = new CompanyBLL();
            List<CompanyModels> com = new List<CompanyModels>();
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            com = bll.getCompany(lang.LangID);
            ViewBag.CompanyListID = new SelectList(com, "CompanyID", "Name");
            return View();

        }
        [HttpPost]
        [Authorize(Roles = "8,9")]
        public ActionResult InsertMobileBanking(FO.Models.MobileBankingInsert banking)
        {
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            MobileBankingBLL cardbll = new MobileBankingBLL();
            CompanyBLL bll = new CompanyBLL();
            List<CompanyModels> com = new List<CompanyModels>();
            com = bll.getCompany(lang.LangID);
            ViewBag.CompanyListID = new SelectList(com, "CompanyID", "Name");
            if (ModelState.IsValid)
            {
                MobileBankingModels items = new MobileBankingModels();
                MobileBankingModels itemsLang = new MobileBankingModels();
                items.MobileBankingName = banking.MobileBankingName;
                items.BenefitContent = WebUtility.HtmlEncode(banking.BenefitContent);
                items.Description = WebUtility.HtmlEncode(banking.Description);
                items.FurtureContent = WebUtility.HtmlEncode(banking.FurtureContent);
                items.MoreFee = WebUtility.HtmlEncode(banking.MoreFee);
                items.MoreInfo = WebUtility.HtmlEncode(banking.MoreInfo);
                items.MoreBenefit = WebUtility.HtmlEncode(banking.MoreBenefit);
                items.CompanyID = banking.CompanyID;
                items.UserPost = User.Identity.Name;
                items.Cost = double.Parse(banking.Cost.Replace(".", "").Replace(".", ""));
                items.Interest = banking.Interest;
                items.Display = false;
                ////
                itemsLang.MobileBankingName = banking.MobileBankingNameLang;
                itemsLang.BenefitContent = WebUtility.HtmlEncode(banking.BenefitContentLang);
                itemsLang.Description = WebUtility.HtmlEncode(banking.DescriptionLang);
                itemsLang.FurtureContent = WebUtility.HtmlEncode(banking.FurtureContentLang);
                itemsLang.MoreFee = WebUtility.HtmlEncode(banking.MoreFeeLang);
                itemsLang.MoreInfo = WebUtility.HtmlEncode(banking.MoreInfoLang);
                itemsLang.MoreBenefit = WebUtility.HtmlEncode(banking.MoreBenefitLang);
                itemsLang.CompanyID = banking.CompanyID;
                itemsLang.UserPost = User.Identity.Name;
                itemsLang.Display = false;
                itemsLang.Cost = double.Parse(banking.Cost.Replace(".", "").Replace(".", ""));
                itemsLang.Interest = banking.Interest;
                cardbll.InsertMobileBanking(items);
                MobileBankingModels carditem = cardbll.getTOP1();
                items.MobileBankingID = carditem.MobileBankingID;
                itemsLang.MobileBankingID = carditem.MobileBankingID;
                cardbll.InsertMobileBankingLanng(items, 1);
                cardbll.InsertMobileBankingLanng(itemsLang, 2);
                return RedirectToAction("ManagerMobileBanking");
            }
            return View(banking);

        }

        [HttpGet]
        [Authorize(Roles = "8,9")]
        public ActionResult UpdateMobileBanking(int MobileBankingID)
        {
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            MobileBankingBLL cardbll = new MobileBankingBLL();
            CompanyBLL bll = new CompanyBLL();
            MobileBankingModels card = new MobileBankingModels();
            List<CompanyModels> com = new List<CompanyModels>();
            com = bll.getCompany(lang.LangID);
            card = cardbll.GetMobileBankingByIDToManager(MobileBankingID, lang.LangID);
            Models.MobileBanking c = new Models.MobileBanking();
            ViewBag.CompanyListID = new SelectList(com, "CompanyID", "Name", card.CompanyID);
            c.MobileBankingName = card.MobileBankingName;
            c.BenefitContent = WebUtility.HtmlDecode(card.BenefitContent);
            c.CompanyID = card.CompanyID;
            c.Description = WebUtility.HtmlDecode(card.Description);
            c.MoreFee = WebUtility.HtmlDecode(card.MoreFee);
            c.MoreInfo = WebUtility.HtmlDecode(card.MoreInfo);
            c.FurtureContent = WebUtility.HtmlDecode(card.FurtureContent);
            c.MoreBenefit = WebUtility.HtmlDecode(card.MoreBenefit);
            c.Display = card.Display;
            c.MobileBankingID = card.MobileBankingID;
            c.Cost = String.Format("{0:0,0}", card.Cost);
            c.Interest = card.Interest;
            return View(c);
        }
        [ValidateInput(false)]
        [HttpPost]
        [Authorize(Roles = "8,9")]
        public ActionResult UpdateMobileBanking(FO.Models.MobileBanking card)
        {
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            MobileBankingBLL cardbll = new MobileBankingBLL();

            CompanyBLL bll = new CompanyBLL();
            MobileBankingModels ca = new MobileBankingModels();
            List<CompanyModels> com = new List<CompanyModels>();
            com = bll.getCompany(lang.LangID);
            ViewBag.CompanyListID = new SelectList(com, "CompanyID", "Name", ca.CompanyID);
            ca = cardbll.GetMobileBankingByIDToManager(card.MobileBankingID, lang.LangID);
            if (ca != null)
            {
                ca.MobileBankingName = card.MobileBankingName;
                ca.BenefitContent = WebUtility.HtmlEncode(card.BenefitContent);
                ca.CompanyID = card.CompanyID;
                ca.Description = WebUtility.HtmlEncode(card.Description);
                ca.MoreFee = WebUtility.HtmlEncode(card.MoreFee);
                ca.MoreInfo = WebUtility.HtmlEncode(card.MoreInfo);
                ca.FurtureContent = WebUtility.HtmlEncode(card.FurtureContent);
                ca.MoreBenefit = WebUtility.HtmlEncode(card.MoreBenefit);
                ca.Display = card.Display;
                ca.MobileBankingID = card.MobileBankingID;
                ca.UserUpdate = User.Identity.Name;
                ca.DateUpdate = DateTime.Now.ToString();
                ca.Cost = double.Parse(card.Cost.Replace(".", "").Replace(".", ""));
                ca.Interest = card.Interest;
                cardbll.UpdateMobileBanking(ca, lang.LangID);
                return RedirectToAction("ManagerMobileBanking");
            }
            return View();


        }

        [HttpPost]
        [Authorize(Roles = "8,9")]
        public JsonResult DeleteMobileBanking(int MobileBankingID)
        {
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            MobileBankingBLL bll = new MobileBankingBLL();
            MobileBankingModels card = new MobileBankingModels();
            card = bll.GetMobileBankingByIDToManager(MobileBankingID, lang.LangID);
            if (card != null)
            {
                bll.DeleteMobileBanking(card.MobileBankingID);
                var result = new { Status = "OK" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }
            else
            {
                var result = new { Status = "Xóa thất bại" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }

        }

        [HttpGet]
        [Authorize(Roles = "8,9")]
        public ActionResult Articles()
        {
            ProductBLL cardbll = new ProductBLL();
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            int MobileBankingID = int.Parse(System.Configuration.ConfigurationManager.AppSettings["MobileBankingID"].ToString());
            ProductModels card = new ProductModels();
            card = cardbll.getProductByID(MobileBankingID, lang.LangID);
            Models.Product c = new Models.Product();
            c.Description = WebUtility.HtmlDecode(card.Description);
            return View(c);
        }
        [ValidateInput(false)]
        [HttpPost]
        [Authorize(Roles = "8,9")]
        public ActionResult Articles(FO.Models.Product card)
        {

            ProductBLL cardbll = new ProductBLL();
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            int MobileBankingID = int.Parse(System.Configuration.ConfigurationManager.AppSettings["MobileBankingID"].ToString());
            ProductModels ca = new ProductModels();
            ca = cardbll.getProductByID(MobileBankingID, lang.LangID);
            if (ca != null)
            {
                ca.Description = WebUtility.HtmlEncode(card.Description);
                cardbll.UpdateProductDesriptionLang(ca, lang.LangID);
                return RedirectToAction("ManagerMobileBanking");
            }

            return View();
        }

        [HttpGet]
        [Authorize(Roles = "8,9")]
        public ActionResult InsertFAQ()
        {

            return View();

        }
        [HttpPost]
        [Authorize(Roles = "8,9")]
        public ActionResult InsertFAQ(FO.Models.ProductFAQInsert card)
        {
            ProductFAQBLL cardbll = new ProductFAQBLL();
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            int MobileBankingID = int.Parse(System.Configuration.ConfigurationManager.AppSettings["MobileBankingID"].ToString());
            if (ModelState.IsValid)
            {
                ProductFAQModels items = new ProductFAQModels();
                items.FAQTitles = card.FAQTitles;
                items.FAQAnwers = card.FAQAnwers;
                items.ProductID = MobileBankingID;
                cardbll.InsertFAQ(items);
                ProductFAQModels faqitems = cardbll.gettop1faq();
                ProductFAQModels itemsLang = new ProductFAQModels();
                items.ProductFAQID = faqitems.ProductFAQID;
                itemsLang.ProductFAQID = faqitems.ProductFAQID;
                cardbll.InsertFAQLang(items, 1);

                itemsLang.FAQTitles = card.FAQTitlesLang;
                itemsLang.FAQAnwers = card.FAQAnwersLang;
                cardbll.InsertFAQLang(itemsLang, 2);
                return RedirectToAction("ManagerFAQ");
            }
            return View(card);

        }

        [HttpGet]
        [Authorize(Roles = "8,9")]
        public ActionResult UpdateFAQ(int ProductFAQID)
        {
            ProductFAQBLL cardbll = new ProductFAQBLL();
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            ProductFAQModels card = new ProductFAQModels();
            card = cardbll.getfaqbyid(ProductFAQID, lang.LangID);
            Models.ProductFAQ c = new Models.ProductFAQ();
            c.FAQTitles = card.FAQTitles;
            c.FAQAnwers = card.FAQAnwers;
            return View(c);
        }
        [ValidateInput(false)]
        [HttpPost]
        [Authorize(Roles = "8,9")]
        public ActionResult UpdateFAQ(FO.Models.ProductFAQ card)
        {
            ProductFAQBLL cardbll = new ProductFAQBLL();
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            ProductFAQModels ca = new ProductFAQModels();

            ca = cardbll.getfaqbyid(card.ProductFAQID, lang.LangID);
            if (ca != null)
            {
                ca.FAQTitles = card.FAQTitles;
                ca.FAQAnwers = card.FAQAnwers;
                cardbll.UpdateFAQ(ca, lang.LangID);
                return RedirectToAction("ManagerFAQ");
            }
            return View();


        }

        [HttpPost]
        [Authorize(Roles = "8,9")]
        public JsonResult DeleteFAQ(int ProductFAQID)
        {
            ProductFAQBLL bll = new ProductFAQBLL();
            LanguageBLL langbll = new LanguageBLL();
            ProductFAQModels card = new ProductFAQModels();

            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);

            card = bll.getfaqbyid(ProductFAQID, lang.LangID);
            if (card != null)
            {
                bll.DeleteFAQ(card.ProductFAQID);
                var result = new { Status = "OK" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }
            else
            {
                var result = new { Status = "Xóa thất bại" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }
        }
        [Authorize(Roles = "8,9")]
        public ActionResult ManagerFAQ()
        {
            return View();
        }
        public JsonResult getFAQJson()
        {
            int MobileBankingID = int.Parse(System.Configuration.ConfigurationManager.AppSettings["MobileBankingID"].ToString());
            ProductFAQBLL cardbll = new ProductFAQBLL();
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            List<ProductFAQModels> list = new List<ProductFAQModels>();

            list = cardbll.getfaqbyproid(MobileBankingID, lang.LangID);

            return Json(list, JsonRequestBehavior.AllowGet);
        }

        public ActionResult ThanksYou()
        {
            return View();
        }
        [HttpGet]
        [Authorize(Roles = "8,9")]
        public ActionResult ContractDetail(int MobileBankingApplyID)
        {
            MobileBankingBLL cardbll = new MobileBankingBLL();
            MobileBankingApplyModels cardapp = new MobileBankingApplyModels();
            cardapp = cardbll.getcontractbyid(MobileBankingApplyID);
            StatusBLL status = new StatusBLL();
            List<StatusModels> liststatus = new List<StatusModels>();
            liststatus = status.getStatus();
            FO.Models.MobileBankingApply c = new FO.Models.MobileBankingApply();
            ViewBag.StatusListID = new SelectList(liststatus, "StatusID", "StatusName", cardapp.StatusID);
            c.StatusID = cardapp.StatusID;
            c.CustomerName = cardapp.CustomerName;
            c.CustomerEmail = cardapp.CustomerEmail;
            c.CustomerDOB = cardapp.CustomerDOB;
            c.CustomerPhone = cardapp.CustomerPhone;
            c.CustomerIncome = cardapp.CustomerIncome;
            c.CompanyName = cardapp.CompanyName;
            c.StatusName = cardapp.StatusName;
            c.MobileBankingName = cardapp.MobileBankingName;
            c.MobileBankingID = cardapp.MobileBankingID;
            c.CompanyImg = cardapp.CompanyImg;
            c.City = cardapp.City;
            c.ContactTime = cardapp.ContactTime;
            c.BusinessLoan = cardapp.BusinessLoan;
            c.SavingsDeposits = cardapp.SavingsDeposits;
            c.HomeLoan = cardapp.HomeLoan;
            c.CarLoan = cardapp.CarLoan;
            c.PersonalLoan = cardapp.PersonalLoan;
            c.CreditCard = cardapp.CreditCard;
            c.CurrentAccount = cardapp.CurrentAccount;
            c.AppDate = cardapp.AppDate;
            return View(c);
        }
        [HttpPost]
        [ValidateInput(false)]
        [Authorize(Roles = "8,9")]
        public ActionResult ContractDetail(FO.Models.MobileBankingApply card)
        {
            MobileBankingBLL cardbll = new MobileBankingBLL();
            MobileBankingApplyModels cardapp = new MobileBankingApplyModels();
            cardapp = cardbll.getcontractbyid(card.MobileBankingApplyID);
            StatusBLL status = new StatusBLL();
            List<StatusModels> liststatus = new List<StatusModels>();
            liststatus = status.getStatus();
            ViewBag.StatusListID = new SelectList(liststatus, "StatusID", "StatusName", cardapp.StatusID);
            if (cardapp != null)
            {
                cardapp.StatusID = card.StatusID;
                cardbll.UpdateStatus(cardapp);
                return RedirectToAction("Contract");
            }
            return View();
        }

        [Authorize(Roles = "8,9")]
        public ActionResult Contract()
        {
            StatusBLL status = new StatusBLL();
            List<StatusModels> liststatus = new List<StatusModels>();
            liststatus = status.getStatus();
            ViewBag.StatusID = liststatus;
            return View();
        }
        public JsonResult getContract()
        {

            MobileBankingBLL cardbll = new MobileBankingBLL();
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            List<MobileBankingApplyModels> list = new List<MobileBankingApplyModels>();
            list = cardbll.getcontract();
            return Json(list, JsonRequestBehavior.AllowGet);
        }

        public JsonResult getcreditcontractbystatus(int StatusID)
        {

            MobileBankingBLL cardbll = new MobileBankingBLL();
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            List<MobileBankingApplyModels> list = new List<MobileBankingApplyModels>();
            list = cardbll.getcontractbystatus(StatusID);
            return Json(list, JsonRequestBehavior.AllowGet);
        }
        [HttpPost]
        [Authorize(Roles = "8,9")]
        public JsonResult DeleteMobileBankingApply(int MobileBankingApplyID)
        {
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            MobileBankingBLL bll = new MobileBankingBLL();
            MobileBankingApplyModels card = new MobileBankingApplyModels();
            card = bll.getcontractbyid(MobileBankingApplyID);
            if (card != null)
            {
                bll.DeleteMobileBankingApply(card.MobileBankingApplyID);
                var result = new { Status = "OK" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }
            else
            {
                var result = new { Status = "Xóa thất bại" };
                return Json(result, JsonRequestBehavior.AllowGet);
            }

        }

        [HttpPost]
        public JsonResult MobileBankingApply(int MobileBankingID, string CustomerName, string CustomerEmail, string CustomerPhone, string CustomerIncome, string CustomerDOB, bool CurrentAccount, bool SavingsDeposits, bool CreditCard, bool HomeLoan, bool CarLoan, bool PersonalLoan, bool BusinessLoan, string City, string ContactTime)
        {
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            MobileBankingBLL bll = new MobileBankingBLL();
            MobileBankingApplyModels cardapp = new MobileBankingApplyModels();
            cardapp.MobileBankingID = MobileBankingID;
            cardapp.CustomerName = CustomerName;
            cardapp.CustomerEmail = CustomerEmail;
            cardapp.CustomerPhone = CustomerPhone;
            cardapp.CustomerIncome = CustomerIncome;
            cardapp.CustomerDOB = CustomerDOB;
            cardapp.CurrentAccount = CurrentAccount;
            cardapp.SavingsDeposits = SavingsDeposits;
            cardapp.CreditCard = CreditCard;
            cardapp.HomeLoan = HomeLoan;
            cardapp.CarLoan = CarLoan;
            cardapp.PersonalLoan = PersonalLoan;
            cardapp.BusinessLoan = BusinessLoan;
            cardapp.City = City;
            cardapp.ContactTime = ContactTime;
            cardapp.StatusID = 1;
            int result = bll.MobileBankingApply(MobileBankingID, cardapp);
            if (result == 1)
            {
                int check = 1;
                return Json(check);
            }
            else
            {
                int check = -1;
                return Json(check);
            }
        }

        public ActionResult MobileBankingsByProvider(int CompanyID)
        {
            MobileBankingBLL MobileBankingbll = new MobileBankingBLL();
            LanguageBLL langbll = new LanguageBLL();
            Language lang = langbll.getLangByCode(Request.Cookies["_culture"]["lang"]);
            ProductBLL probll = new ProductBLL();
            int MobileBankingID = int.Parse(System.Configuration.ConfigurationManager.AppSettings["MobileBankingID"].ToString());
            ViewBag.MobileBanking = MobileBankingbll.getMobileBankingbyProvider(CompanyID, lang.LangID);
            ViewBag.ProDes = probll.getProductByID(MobileBankingID, lang.LangID);
            return View();

        }
        [HttpPost]
        public ActionResult SendEmail(string Name, string phone, string emailuser, int CardID)
        {
            try
            {
                string MailFromUserName = ConfigurationManager.AppSettings["MailFromUserName"].ToString();
                string MailFromPassword = ConfigurationManager.AppSettings["MailFromPassword"].ToString();
                string MailSMTP = ConfigurationManager.AppSettings["MailSMTP"].ToString();
                string MailCC = ConfigurationManager.AppSettings["MailCC"].ToString();
                string MailSendTo = ConfigurationManager.AppSettings["MailSendTo"].ToString();
                Models.EmailSend email = new Models.EmailSend();
                email.EmailSendTo = MailSendTo;
                email.Subject = "Khách hàng " + Name + " Apply Mobile Banking ID: " + CardID + "";
                email.Body = "";
                email.Body += "<p>Hi, Admin</p>";
                email.Body += "<p>Khách hàng: " + Name + " Apply Mobile Banking ID: " + CardID + "</p>";
                email.Body += "<p>Email: " + emailuser + "</p>";
                email.Body += "<p>SĐT: " + phone + "</p>";
                email.Body += "<p><a href='http://www.vnbanknet.com/MobileBanking/ContractDetail/" + CardID + "'>Link chi tiết</a></p>";
                email.Body += "<p>Thanks</p>";
                MailMessage message = new MailMessage();
                message.Body = email.Body;
                message.IsBodyHtml = true;
                message.From = new System.Net.Mail.MailAddress(MailFromUserName);
                message.To.Add(email.EmailSendTo);
                message.CC.Add(MailCC);
                message.Subject = email.Subject;

                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(MailSMTP);// you need an smtp server address to send emails
                smtp.Credentials = new System.Net.NetworkCredential(MailFromUserName, MailFromPassword); //missing line from ur code
                smtp.Port = 587;  //missing line from your code
                smtp.EnableSsl = true;   //missing line from your code
                smtp.Send(message);
                int result = 1;
                return Json(result, JsonRequestBehavior.AllowGet);
            }
            catch
            {
                int result = -1;
                return Json(result, JsonRequestBehavior.AllowGet);
            }
        }


    }
}
